Polygons#
Download this notebook from GitHub (right-click to download).
import hvplot.pandas # noqa
Using hvplot with geopandas is as simple as loading a geopandas dataframe and calling hvplot on it with geo=True.
import geopandas as gpd
countries = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
countries.sample(5)
| pop_est | continent | name | iso_a3 | gdp_md_est | geometry | |
|---|---|---|---|---|---|---|
| 147 | 108116615.0 | Asia | Philippines | PHL | 376795 | MULTIPOLYGON (((120.83390 12.70450, 120.32344 ... |
| 73 | 1148130.0 | Africa | eSwatini | SWZ | 4471 | POLYGON ((32.07167 -26.73382, 31.86806 -27.177... |
| 84 | 9770529.0 | Asia | United Arab Emirates | ARE | 421142 | POLYGON ((51.57952 24.24550, 51.75744 24.29407... |
| 72 | 30366036.0 | Africa | Mozambique | MOZ | 15291 | POLYGON ((34.55999 -11.52002, 35.31240 -11.439... |
| 107 | 82913906.0 | Asia | Iran | IRN | 453996 | POLYGON ((48.56797 29.92678, 48.01457 30.45246... |
countries.hvplot(geo=True)
Control the color of the elements using the c option.
countries.hvplot.polygons(geo=True, c='pop_est', hover_cols='all')
You can even color by another series, such as population density:
countries.hvplot.polygons(geo=True, c=countries.pop_est/countries.area, clabel='pop density')
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.
Download this notebook from GitHub (right-click to download).